package com.dragon.manage.action;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dragon.manage.bean.ManageUser;
import com.dragon.manage.bean.MatchInfo;
import com.dragon.manage.service.IManageFinanceService;
import com.dragon.manage.service.IManageService;
import com.dragon.manage.util.LogUtil;
import com.dragon.manage.util.ManageUtil;
import com.dragon.manage.util.RightUtil;
import com.dragon.manage.util.StaticData;
import com.dragon.manage.util.StringUtil;
import com.dragon.manage.util.TimeUtil;
import com.opensymphony.xwork2.ActionContext;

/**
 * 财务管理
 * @author 34225_000
 *
 */
@SuppressWarnings("rawtypes")
public class ManageFinanceAction   extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private IManageService manageService;
	
	private IManageFinanceService manageFinanceService;
	
	public IManageFinanceService getManageFinanceService() {
		return manageFinanceService;
	}

	public void setManageFinanceService(IManageFinanceService manageFinanceService) {
		this.manageFinanceService = manageFinanceService;
	}

	public IManageService getManageService() {
		return manageService;
	}

	public void setManageService(IManageService manageService) {
		this.manageService = manageService;
	}

	/**
	 * 獲取開始的比賽列表
	 * @return
	 */
	public String getbeginningMatchList(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String page=request.getParameter("page");
			//类型
			String type=request.getParameter("type");
			if(page==null||type==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.getBeginMatchList(Integer.parseInt(type),Integer.parseInt(page));
			//返回参数
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.ok.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("獲取開始的比賽列表",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	/**
	 * 结算
	 */
	public String settleMatch(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		long startTime = TimeUtil.getSysCurTimeMillis();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			/*
			 * 获取参数
			 */
			String matchId=request.getParameter("matchId");
			String settleTypes=request.getParameter("settleType");
			if(matchId==null||settleTypes==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			/*
			 * 判断结算类型
			 */
			int settleType = Integer.parseInt(settleTypes);
			if(settleType!=StaticData.AmusementStatus.cancellation.getType()&&
					settleType!=StaticData.AmusementStatus.entertained.getType()){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			//结算
			result = manageFinanceService.settleMatch(Integer.parseInt(matchId),settleType);
			LogUtil.warn("==================================");
			LogUtil.warn("发奖总消耗时间："+(TimeUtil.getSysCurTimeMillis()-startTime));
			LogUtil.warn("==================================");
			//返回参数
//			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.ok.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("作废下注失败",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/**
	 * 获取游戏竞猜列表
	 * @return
	 */
	public String getAmusementIntoList(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String matchId=request.getParameter("matchId");
			if(matchId==null||matchId.isEmpty()){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			//获取比赛信息
			MatchInfo matchInfo = manageFinanceService.getMatchInfoById(Integer.parseInt(matchId));
			if(matchInfo==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			//获取竞猜列表
			JSONArray  amusementInfoList = manageFinanceService.getAmusementInfoList(matchInfo.getId());
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.ok.getType());
			result.put(StaticData.reKey.amusementInfoList.getKey(), amusementInfoList);
			ct.put(StaticData.reKey.result.getKey(), result);
		} catch (Exception e) {
			LogUtil.error("获取游戏竞猜列表",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
		return StaticData.RE_SUCCESS;
	}

	
	/**
	 * 审核结果
	 * @return
	 */
	public String checkResult(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			//主键id
			String amusementInfoId=request.getParameter("amusementInfoId");
			//结果
			String amusementResult=request.getParameter("amusementResult");
			if(amusementInfoId == null||amusementResult==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			int code = manageFinanceService.checkResult(Integer.parseInt(amusementInfoId),
					Integer.parseInt(amusementResult) );
			
			//返回参数
			result.put(StaticData.reKey.code.getKey(), code);
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("审核结果失败",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/*
	 * 二次确认结果提交
	 */
	public String submitResult(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			//对应的比赛id
			String matchId=request.getParameter("matchId");
			if(matchId==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			int code = manageFinanceService.submitResult(Integer.parseInt(matchId),manageUser);
			
			//返回参数
			result.put(StaticData.reKey.code.getKey(),code);
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("二次确认结果提交失败",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}

	/**
	 * 驳回结果
	 */
	public String rejectResult(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			//对应的比赛id
			String matchId=request.getParameter("matchId");
			if(matchId==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			
			int code = manageFinanceService.rejectResult(Integer.parseInt(matchId),manageUser);
			
			//返回参数
			result.put(StaticData.reKey.code.getKey(),code);
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("驳回结果失败",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/**
	 * 比赛奖金分配列表
	 */
	public String getAwardDistributionList(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			/*
			 * 前台页面传来的type和page
			 * 如果有则生成type如果没有则不带参数页面
			 */
			String pages =request.getParameter("page");
			String types =request.getParameter("type");
			int page = StaticData.no_param;
			int type = StaticData.no_param;
			if(types!=null&&!types.isEmpty()){
				type = Integer.parseInt(types);
			}
			if(pages!=null&&!pages.isEmpty()){
				page = Integer.parseInt(pages);
			}
			//获取结算列表
			result = manageFinanceService.getAwardDistributionList(type, page);
			
			//返回参数
			result.put(StaticData.reKey.code.getKey(),StaticData.codeType.ok.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("比赛奖金分配列表",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/**
	 * 获取用户白名单列表
	 */
	public String getWhiteUserList(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String pages =request.getParameter("page");
			int page = StaticData.no_param;
			if(pages!=null&&!pages.isEmpty()){
				page = Integer.parseInt(pages);
			}
			//获取结算列表
			result = manageFinanceService.getWhiteUserList(page);
			
			//返回参数
			result.put(StaticData.reKey.code.getKey(),StaticData.codeType.ok.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("获取用户白名单列表",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/**
	 * 新增白名单
	 */
	public String addWhiteUser(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String userId =request.getParameter("userId");
			if(userId==null||userId.isEmpty()){
				result.put(StaticData.reKey.code.getKey(),StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.addWhiteUser(Integer.parseInt(userId));
			
			//返回参数
			result.put(StaticData.reKey.code.getKey(),StaticData.codeType.ok.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("获取用户白名单列表",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	/**
	 * 获取某个用户信息
	 * @return
	 */
	public String getUserInfo(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String userId =request.getParameter("userId");
			if(userId==null||userId.isEmpty()){
				result.put(StaticData.reKey.code.getKey(),StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.getUserInfo(Integer.parseInt(userId));
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("获取用户白名单列表",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	/**
	 * 更新白名单金币
	 */
	public String addWhiteUserMoney(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser = ManageUtil.getManageUserBySession(ct, result,
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String userId =request.getParameter("userId");
			String amount =request.getParameter("amount");
			if(userId==null||userId.isEmpty()||
					amount==null||amount.isEmpty()){
				result.put(StaticData.reKey.code.getKey(),StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.addWhiteUserMoney(Integer.parseInt(userId), 
					Integer.parseInt(amount),manageUser.getId());
			//返回参数
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("获取用户白名单列表",e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/**
	 * 获取活动列表
	 * @return
	 */           
	public String getActiveListFinance(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, 
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String page=request.getParameter("page");
			if(page==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.getActiveList(StringUtil.getParam(page));
			
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("获取活动列表", e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/**
	 * 获取活动选项列表
	 * @return
	 */
	public String getActivityOptionListFinance(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, 
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String activeId=request.getParameter("activeId");
			if(activeId==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.getActivityOptionList(StringUtil.getParam(activeId));
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("获取活动选项列表", e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}

	/**
	 * 更新活动选项
	 * @return
	 */
	public String updateActivityOptionFinance(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, 
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String id=request.getParameter("id");
			if(id==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			/** 活动结果 */
			String amusementResult=request.getParameter("amusementResult");
			result = manageFinanceService.updateActivityOption(StringUtil.getParam(id),StringUtil.getParam(amusementResult));
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("更新活动选项", e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}

	/**
	 * 提交结果
	 */
	public String overActivityOptionFinance(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, 
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String activityId=request.getParameter("activityId");
			if(activityId==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}

			result = manageFinanceService.overActivityOption(StringUtil.getParam(activityId));
			
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("提交结果", e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}
	
	/**
	 * 活动发奖列表
	 */
	public String activityAwardListFinance(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, 
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String page=request.getParameter("page");
			if(page==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.activityAwardList(StringUtil.getParam(page));
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("活动发奖列表", e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}

	/**
	 * 获取竞猜成功的人
	 */
	public String guessWinnerListFinance(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, 
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String page=request.getParameter("page");
			String activeId=request.getParameter("activeId");
			if(page==null&&activeId==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.guessWinnerList(StringUtil.getParam(activeId),
					StringUtil.getParam(page));
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("获取竞猜成功的人", e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}

	/**
	 * 发奖
	 */
	public String updateActivityWinnerFinance(){
		/*
		 * 容器和返回的json值
		 */
		ActionContext ct=ActionContext.getContext();
		JSONObject result = new JSONObject();
		try {
			/*
			 * 再通过sessionid获取用户信息
			 */
			ManageUser manageUser =  ManageUtil.getManageUserBySession(ct, result, 
					request,manageService, RightUtil.getRightId(this.getClass().getName()));
			if(manageUser==null){
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			String CDK=request.getParameter("CDK");
			String userBetId=request.getParameter("userBetId");
			if(CDK==null&&userBetId==null){
				result.put(StaticData.reKey.code.getKey(), StaticData.codeType.param_error.getType());
				ct.put(StaticData.reKey.result.getKey(), result);
				return StaticData.RE_SUCCESS;
			}
			result = manageFinanceService.updateActivityWinner(StringUtil.getParam(userBetId),
					CDK);
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		} catch (Exception e) {
			LogUtil.error("发奖", e);
			result.put(StaticData.reKey.code.getKey(), StaticData.codeType.other_error.getType());
			ct.put(StaticData.reKey.result.getKey(), result);
			return StaticData.RE_SUCCESS;
		}
	}

}
